
#include <endian.h>
namespace bits {


	inline
	uint16_t swap_byte_order (uint16_t n) {
		return (((n & 0x00FF) << 8 ) |
			((n & 0xFF00) >> 8 ));
	}

	inline
	uint32_t swap_byte_order (uint32_t n) {
		return (((n & 0x000000FF) << 24) |
			((n & 0x0000FF00) << 8 ) |
			((n & 0x00FF0000) >> 8 ) |
			((n & 0xFF000000) >> 24));
	}

	inline
	uint64_t swap_byte_order (uint64_t n) {
		return (((n & 0x00000000000000FF) << 56) |
			((n & 0x000000000000FF00) << 40) |
			((n & 0x0000000000FF0000) << 24) |
			((n & 0x00000000FF000000) << 8 ) |
			((n & 0x000000FF00000000) >> 8 ) |
			((n & 0x0000FF0000000000) >> 24) |
			((n & 0x00FF000000000000) >> 40) |
			((n & 0xFF00000000000000) >> 56));
	}
	
} // namespace utils
